DeriveGamemode("sandbox")
GM.Name="deRP"
GM.Author="Alex Powell"

-- Jobs --
function GM:CreateTeams()
	team.SetUp(1,"Citizen",Color(50,205,50,255),true)
	team.SetUp(2,"Doctor",Color(50,205,50,255),true)
	team.SetUp(3,"Shop Owner",Color(50,205,50,255),true)
	team.SetUp(4,"Rebel",Color(50,205,50,255),true)
	team.SetUp(5,"Rebel Arms Dealer",Color(50,205,50,255),true)
	team.SetUp(6,"Rebel Spy",Color(67,110,238,255),true)
	team.SetUp(7,"Rebel Leader",Color(50,205,50,255),true)
	team.SetUp(8,"Civil Protection",Color(67,110,238,255),true)
	team.SetUp(9,"Combine Soldier",Color(0,51,255,255),true)
	team.SetUp(10,"Combine Elite",Color(255,255,255,255),true)
end
local CitMdl="models/player/Group01/Male_0"..math.random(1,9)..".mdl"
Jobs={
{CitMdl,{"weapon_mad_fists","keys"},"Basic citizen, nothing special."},--Citizen
{CitMdl,{"weapon_mad_fists","keys"},"As a Doctor you heal other citizens... for a price."},--Doctor
{CitMdl,{"weapon_mad_fists","keys"},"Sell items to make money."},--Shop Owner
{CitMdl,{"weapon_mad_knife","weapon_mad_fists","keys"},"Basic resistance against the combine, cause trouble for them and protect your fellow citizen."},--Rebel
{CitMdl,{"weapon_mad_knife","weapon_mad_fists","keys"},"Provide your fellow rebels with weaponry to fight the combine."},--Rebel Arms Dealer
{"models/player/Police.mdl",{"weapon_mad_knife","weapon_mad_usp_match","item_ammo_pistol_large","weapon_stunstick","combine_keycard"},"Go under cover in the Nexus or other combine occupied areas to gather inteligence."},--Rebel Spy
{CitMdl,{"weapon_mad_knife","weapon_mad_fists","keys"},"Co-ordinate all the rebels to cause maximum problems for the combine."},--Rebel Leader
{"models/player/Police.mdl",{"weapon_mad_usp_match","item_ammo_pistol_large","weapon_stunstick","combine_keycard"},"Basic combine class, the main street patrol."},--Civil Protection
{"models/player/Combine_Soldier.mdl",{"combine_keycard","weapon_mad_mp7","item_ammo_smg1_large"},"Heavier armed for a reason, use against hordes of rebels."},--Combine Soldier
{"models/player/Combine_Super_Soldier.mdl",{"combine_keycard","weapon_mad_ar2","item_ammo_ar2_large"},"Command the combine so that their in the right place at the right time to keep control of the city."},--Combine Elite
--{"mdl",{"swep1","swep2"},"Description"}--Example
}
JobItems={
{},--Citizen
{{"MedKit_sm",5,"Small Medkit","Heals 20 HP"},{"MedKit_lg",8,"Large Medkit","Heals 40 HP"}},--Doctor
{},--Shop Owner
{},--Rebel
{},--Rebel Arms Dealer
{},--Rebel Spy
{},--Rebel Leader
{{"ration_pack",0,"Ration Pack","Contains Money"}},--Civil Protection
{{"ration_pack",0,"Ration Pack","Contains Money"}},--Combine
{{"ration_pack",0,"Ration Pack","Contains Money"}}--Combine Elite
--{{"Ent_1",price,"Entity Name","Entity Description"},{"Ent_2",price,"Entity Name","Entity Description"}}--Example
}

-- Player damage sounds --
function PainSound(ply)
	if SERVER then
		if ply:IsPlayer() then
			if ply:Team()==8 then
				if ply:Health()<=0 then
					ply:EmitSound("npc/metropolice/die"..math.random(1,4)..".wav",100,100)
				else
					ply:EmitSound("npc/metropolice/pain"..math.random(1,4)..".wav",100,100)
				end
			elseif ply:Team()==9||ply:Team()==10 then
				if ply:Health()<=0 then
					ply:EmitSound("npc/combine_soldier/die"..math.random(1,3)..".wav",100,100)
				else
					ply:EmitSound("npc/combine_soldier/pain"..math.random(1,3)..".wav",100,100)
				end
			else
				ply:EmitSound("vo/npc/male01/pain0"..math.random(1,9)..".wav",100,100)
			end
		end
	end
end
hook.Add("EntityTakeDamage","DmgSound",PainSound)

function RegenerateHealth()
	for k,v in pairs(player.GetAll()) do
		if v:Alive() then
			v:SetHealth(math.min(v:Health()+1,math.max(100,100)))
		end
	end
	timer.Simple(5,RegenerateHealth)
end
RegenerateHealth()

-- Door check for combine keycard --
local metaE=FindMetaTable("Entity")
function metaE:IsDoor()
	local class=self:GetClass()
	if class=="func_door" then
		return true
	end
	return false
end